package com.liberty.dasheen.admin.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liberty.dasheen.admin.sys.service.StaticValueService;
import com.liberty.dasheen.common.BaseController;
import com.liberty.dasheen.entity.SysStaticValue;

@Controller
@RequestMapping("/admin/sys/static")
public class StaticController extends BaseController {
	
	@Autowired
	private StaticValueService staticValueService;

	@RequestMapping("/list")
	@ResponseBody
	public List<SysStaticValue> listByType(@RequestBody String json) {
		try {

			SysStaticValue sv = super.jsonToObject(json, SysStaticValue.class);
			System.out.println(sv.getStaticType());
			List<SysStaticValue> list = staticValueService.listByType(sv.getStaticType());
			return list;
		} catch (Exception e) {
			System.out.println("StaticController | listByType | Exception:" + e);
			return null;
		}
	}
	
}
